#pragma once
#include "Mesh.h"
#include "Fysics/Dependencies.h"

namespace Fysics
{
	class MeshGroup
	{
	private:
		std::vector<Mesh*> m_Meshes;
		std::string m_Name;
		MeshGroup* m_Parent;
		std::vector<MeshGroup*> m_Children;

		glm::mat4 m_OriginModelMat;

		glm::vec3 m_Position;
		glm::vec3 m_Rotation;
		glm::vec3 m_Scaling;

	public:
		MeshGroup();
		virtual ~MeshGroup();

		void AddMesh(Mesh* mesh);
		Mesh* GetMesh(int index);
		size_t GetSize() const { return m_Meshes.size(); }

		void SetName(const std::string& name) { m_Name = name; }
		std::string GetName() const { return m_Name; }

		void SetParent(MeshGroup* parent) { m_Parent = parent; }
		MeshGroup* GetParent() { return m_Parent; }

		void AddChild(MeshGroup* child);
		MeshGroup* GetChild(int index) const;
		size_t GetChildrenNum() { return m_Children.size(); }

		void SetOriginModelMatrix(const glm::mat4& modelMatrix) { m_OriginModelMat = modelMatrix; }
		void SetPosition(const glm::vec3& position) { m_Position = position; }
		void SetRotation(const glm::vec3& rotation) { m_Rotation = rotation; }
		void SetScaling(const glm::vec3& scaling) { m_Scaling = scaling; }
		glm::mat4 GetModelMatrix() const;

		void Draw(const glm::mat4& itemModelMat);
	};
}